import pymongo
from urllib import parse
username = parse.quote_plus('root')   # 对用户名进行编码
password = parse.quote_plus('123456')  # 对密码进行编码
database = "admin"  # 数据库名称
host = "43.143.162.69"
port = "27017"
mongo = pymongo.MongoClient('mongodb://%s:%s@%s:%s/%s' % (username, password, host, port, database))
print(mongo)
